﻿package com.msjt.action;

import javax.annotation.Resource;

import com.msjt.base.BaseAction;
import com.msjt.entity.Company;
import com.msjt.service.ICompanyService;

@SuppressWarnings("serial")
public class CompanyAction extends BaseAction {
	private Company company;
	@Resource
	private ICompanyService companyService;

	public Company getCompany() {
		return company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

	public ICompanyService getCompanyService() {
		return companyService;
	}

	public void setCompanyService(ICompanyService companyService) {
		this.companyService = companyService;
	}

	// 得到公司信息
	public String getCompanyInfo() throws Exception {
		Company com = this.companyService.getCompanyInfo();
		this.getRequest().put("companyInfo", com);
		return "showCompany";
	}

	// 修改之前的操作
	public String preUpdateCompany() throws Exception {
		Company com = this.companyService.getCompanyInfo();
		this.getRequest().put("companyInfo", com);
		return "updateCompany";
	}

	// 修改公司信息，修改之前需要得到公司的信息
	public String updateCompany() throws Exception {
		boolean flag = this.companyService.updateCompany(this.company);
		if (!flag) {
			this.getRequest().put("msg",
					"<script>alert('修改失败！');history.go(-1);</script>");
			return "error";
		}
		return this.getCompanyAdmin();
	}

	// 得到公司信息
	public String getCompanyDesc() throws Exception {
		Company com = this.companyService.getCompanyInfo();
		this.getRequest().put("companyInfo", com);
		return "gsjj";
	}

	// 后台得到公司信息
	public String getCompanyAdmin() throws Exception {
		Company com = this.companyService.getCompanyInfo();
		this.getRequest().put("companyInfo", com);
		return "companyInfo";
	}
}
